<?php

/**
 * 夏日葵电商系统
 * http://www.xiarikui.com
 */

namespace Xcx\Controller;

use Xcx\Model\QuestionModel;

class QuestionController extends XcxBaseController {

    public function __construct() {
        parent::__construct();
        $this->questionModel = new QuestionModel();
    }


    /**
     * 开始提问
     */
    public function push(){
        if(!$this->user_id){
            jsonReturn();
        }
        $post = I('post.');
        $res = $this->questionModel->push($post);
        jsonReturn($res['status'] ? $res['result'] : false,$res['msg']);
    }

    /**
     * 采纳
     */
    public function adoption(){
        if(!$this->user_id){
            jsonReturn();
        }
        $post = I('post.');
        $res = $this->questionModel->adoption($post);

        $this->jsonReturn($res['status'],'',array('num' => $res['num'], 'state' => $res['state']));
    }

    /**
     * 收藏
     */
    public function collect(){
        if(!$this->user_id){
            jsonReturn();
        }
        $post = I('post.');
        //$post['question_id'] = $post['collect_state'] =1;
        $res = $this->questionModel->collect($post);
        jsonReturn($res['status']);
    }
}
